import GlobalComponent from './global-component'

import Alert from './alert'
import EditText from './edit-text'
import PreviewImage from './preview-image'
import Confirm from './confirm'
import Console from './console'
import SetTitle from './set-title'
import Loading from './loading-line'
import Modal from './modal'
import ImageUpload from './image-upload'
import SearchInput from './search-input'
import Tabs from './tabs'
import Status from './status'
import Xmap from './map'
import Chart from './chart'
import Ring from './chart/ring.vue'
import ChartLine from './chart/line.vue'
import ListItem from './list-item'
import StatusList from './status-list'
const components = {
  Alert,
  EditText,
  PreviewImage,
  Confirm,
  Console,
  SetTitle,
  Loading,
  ImageUpload,
  Modal,
  SearchInput,
  Tabs,
  Status,
  Chart,
  Ring,
  ChartLine,
  ListItem,
  StatusList,
  Xmap
}

const install = function (Vue, opts = {}) {
  if (install.installed) return

  // 注册全局方法

  // 注册全局组件
  for (let name in components) {
    Vue.component(name, components[name])
  }

  // 注册实例方法
  Vue.prototype.$Alert = new GlobalComponent(Alert, Vue)
  Vue.prototype.$Loading = new GlobalComponent(Loading, Vue)
  Vue.prototype.$EditText = new GlobalComponent(EditText, Vue)
  Vue.prototype.$PreviewImage = new GlobalComponent(PreviewImage, Vue)
  Vue.prototype.$Confirm = new GlobalComponent(Confirm, Vue)
  Vue.prototype.$Title = new GlobalComponent(SetTitle, Vue)
  Vue.prototype.$Console = new GlobalComponent(Console, Vue)
}

export default {
  install
}
